package com.boardour.socket.server;

import android.util.Log;

import com.boardour.socket.client.TCPClientPresenter;
import com.boardour.socket.client.WifiClientPresenter;
import com.boardour.socket.foo.constants.TCPConstants;
import com.boardour.socket.listener.OnReceiveListener;

import java.net.InetAddress;

public class WifiServerPresenter {
    private TCPClientPresenter client = new TCPClientPresenter();
    private TCPServerPresenter server = new TCPServerPresenter();
    private static WifiServerPresenter instance = new WifiServerPresenter();

    public static WifiServerPresenter getInstance() {
        return instance;
    }

    private WifiServerPresenter() {
    }

    public TCPClientPresenter getClient() {
        return client;
    }

    public TCPServerPresenter getServer() {
        return server;
    }

    public void start() {
        server.start();
    }


    public void close() {
        client.close();
        server.close();
    }

    /**
     * 连接客户端
     */
    public void connectClient(InetAddress address) {
        Log.e("TAG","connectClient");
        client.connect(address, TCPConstants.PORT_CLIENT);
    }

    public void setOnReceiveListener(OnReceiveListener onReceiveListener) {
        server.setOnReceiveListener(onReceiveListener);
    }
}
